home *** CD-ROM | disk | FTP | other *** search
- Path: rain.fr!news
- From: Fabien Bergeret <fbergeret@nahua.arcanet.fr>
- Newsgroups: comp.lang.c++
- Subject: Re: [Q] Missinterpreting *protected* access modifier?
- Date: Fri, 26 Jan 96 10:38:32 WET
- Organization: CSI InterNetNews site
- Message-ID: <NEWTNews.822653031.16436.fbergeret@nahua.arcanet.fr>
- References: <DLrCGF.G1F@wn.planet.gen.nz>
- NNTP-Posting-Host: nahua.arcanet.fr
- Mime-Version: 1.0
- Content-Type: TEXT/PLAIN; charset=US-ASCII
- X-Newsreader: NEWTNews & Chameleon -- TCP/IP for MS Windows from NetManage
-
-
-
- > class A
- > {
- > protected:
- > int i;
- > int GetInt() { return i; };
- > };
- >
- > class B : public A
- > {
- > protected:
- > int Foo(A * pA) { return pA->GetInt(); };
- > };
-
- Protected means that you inherit the methods. For instance, you can
- have a B class :
- class B : public A
- {
- public:
- int GetIntB()
- {
- return GetInt();
- }
- };
- You call on "this" protected methods from A.
- On your example, you call a method on a non-this object, in which you
- cannot call GetInt, since it's not public. I don't really understand the
- meaning of your B class. I woudl have written
- class B : public A
- {
- public:
- Foo()
- {
- return GetInt();
- }
- };
-
- Hope thie helps
-
-